package com.csq.androidproject.ui.activitys;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.csq.androidproject.R;
import com.csq.androidproject.views.draggridview.MyDragGridView;

public class DragGridViewActivity extends Activity {
    
    private MyDragGridView dgvDragView;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_drag_grid_view);
        
        dgvDragView = (MyDragGridView)findViewById(R.id.dgvDragView);
        dgvDragView.setAdapter(new GridViewAdapter());
    }
    
    class GridViewAdapter extends BaseAdapter{
        
        LayoutInflater inflater;
        
        public GridViewAdapter(){
            inflater = LayoutInflater.from(getApplicationContext());
        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return 10;
        }

        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            if(convertView == null){
                convertView = inflater.inflate(R.layout.item_drag_grid, null);
            }
            TextView tvName = (TextView)convertView.findViewById(R.id.tvName);
            tvName.setText(""+position);
            return convertView;
        }
        
    }
    
    
}
